package com.ruoyi.account.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.account.mapper.TbAccountMapper;
import com.ruoyi.account.domain.TbAccount;
import com.ruoyi.account.service.ITbAccountService;

/**
 * 账户Service业务层处理
 * 
 * @author 刘凯豪
 * @date 2025-05-08
 */
@Service
public class TbAccountServiceImpl implements ITbAccountService 
{
    @Autowired
    private TbAccountMapper tbAccountMapper;

    /**
     * 查询账户
     * 
     * @param accountId 账户主键
     * @return 账户
     */
    @Override
    public TbAccount selectTbAccountByAccountId(Long accountId)
    {
        return tbAccountMapper.selectTbAccountByAccountId(accountId);
    }

    /**
     * 查询账户列表
     * 
     * @param tbAccount 账户
     * @return 账户
     */
    @Override
    public List<TbAccount> selectTbAccountList(TbAccount tbAccount)
    {
        String code = UUID.randomUUID().toString().replace("-", "");
        tbAccount.setCode(code);
        return tbAccountMapper.selectTbAccountList(tbAccount);
    }

    /**
     * 新增账户
     * 
     * @param tbAccount 账户
     * @return 结果
     */
    @Override
    public int insertTbAccount(TbAccount tbAccount)
    {
        return tbAccountMapper.insertTbAccount(tbAccount);
    }

    /**
     * 修改账户
     * 
     * @param tbAccount 账户
     * @return 结果
     */
    @Override
    public int updateTbAccount(TbAccount tbAccount)
    {
        return tbAccountMapper.updateTbAccount(tbAccount);
    }

    /**
     * 批量删除账户
     * 
     * @param accountIds 需要删除的账户主键
     * @return 结果
     */
    @Override
    public int deleteTbAccountByAccountIds(Long[] accountIds)
    {
        return tbAccountMapper.deleteTbAccountByAccountIds(accountIds);
    }

    /**
     * 删除账户信息
     * 
     * @param accountId 账户主键
     * @return 结果
     */
    @Override
    public int deleteTbAccountByAccountId(Long accountId)
    {
        return tbAccountMapper.deleteTbAccountByAccountId(accountId);
    }
}
